package com.game.framework.dao;

import com.game.framework.dao.entity.RoleEntity;
import com.game.framework.dao.redis.EnumRedisKey;
import com.game.framework.dao.redis.IRedisKeyConfig;
import com.game.framework.dao.repository.RoleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleDao extends AbstractDao<RoleEntity, Long>{

	@Autowired
	protected RoleRepository roleRepository;
	
	@Override
	protected IRedisKeyConfig getRedisKey() {
		return EnumRedisKey.PlayerInfo;
	}

	@Override
	protected MongoRepository<RoleEntity, Long> getMongoRepository() {
		return roleRepository;
	}

	@Override
	protected Class<RoleEntity> getEntityClass() {
		return RoleEntity.class;
	}

	public List<RoleEntity> selectByUserId(Long userId) {
		return roleRepository.findByUserId(userId);
	}

	RoleEntity selectByRoleId(Long roleId){
		return roleRepository.findByRoleId(roleId);
	}
}
